package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileInputStreamOutputStreamTest {
    public static void main(String[] args) throws IOException {
        //创建文件输入流 用于读取数据
        FileInputStream fileInputStream = new FileInputStream("./img.png");
        //创建文件输出流 用于向文件写入数据
        FileOutputStream fileOutputStream = new FileOutputStream("./img_cp.png");
        long start = System.currentTimeMillis();
        int data;
        while ((data = fileInputStream.read()) != -1) {
            fileOutputStream.write(data);
        }
        long end = System.currentTimeMillis();
        System.out.println("本次运行:" + (end - start) + "毫秒");
        fileInputStream.close();
        fileOutputStream.close();
    }
}
